package com.czxy.servlet;

import cn.itcast.servlet.BaseServlet;
import com.alibaba.fastjson.JSON;
import com.czxy.domain.Category;
import com.czxy.service.CategoryService;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.List;

@WebServlet("/categoryServlet")
public class CategoryServlet extends BaseServlet {



    public  void findAll() throws IOException {

        //调用 service 获取 list
        CategoryService service = new CategoryService();
        List<Category> list = service.findAll();

        // list -- json
        String s = JSON.toJSONString(list);

        //响应
        getResponse().getWriter().write(s);


    }








}
